import { createRouter, createMemoryHistory, RouteRecordRaw } from "vue-router";

declare module 'vue-router' {
    interface RouteMeta {
        title: string,
        transition: string
    }
}

const routes: Array<RouteRecordRaw> = [
    // {
    //     path: "/",
    //     name: "footer",
    //     component: () => import('../components/footer.vue'),
    //     children: [{

    //         path: "",
    //         name: "login",
    //         component: () => import('../components/login.vue')
    //     }, {

    //         path: "reg",
    //         name: "reg",
    //         component: () => import('../components/reg.vue')
    //     }]
    // },

    // {

    //     path: "/",
    //     component: () => import('../components/root.vue'),
    //     redirect: to => {
    //         console.log(to, '=>');
    //         return {
    //             path: "/user1",
    //             query: {
    //                 name: "小满"
    //             }
    //         }
    //     },
    //     children: [
    //         {
    //             path: '/user1',
    //             components: {
    //                 default: () => import('../components/A.vue')
    //             }
    //         }, {
    //             path: '/user2',
    //             components: {
    //                 bbb: () => import('../components/B.vue'),
    //                 ccc: () => import('../components/C.vue')

    //             }
    //         }

    //     ]
    // }

    {
        path: "/",
        component: () => import('../view/login.vue'),
        meta: {
            title: "登录页面",
            transition: 'animate__bounceIn'
        }
    },
    {
        path: "/index",
        component: () => import('../view/index.vue'),
        meta: {
            title: "首页",
            transition: 'animate__bounceInLeft'

        }
    }
]

const router = createRouter({
    history: createMemoryHistory(),
    scrollBehavior: (to, from, savePosition) => {
        console.log(savePosition)
        if (savePosition) {
            return savePosition
        } else {
            return { top: 0 }
        }
    },
    routes

})

export default router